package com.fangzhi;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fangzhi.mobel.OrderLogistics;
import com.fangzhi.mobel.Orders;
import com.fangzhi.service.OrderLogisticsService;
import com.fangzhi.service.OrdersService;
import org.checkerframework.checker.units.qual.A;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class ChangeOrderStatus {

    @Autowired
    private OrdersService ordersService;

    @Autowired


    private OrderLogisticsService orderLogisticsService;

    @Test
    public  void  start(){
        List<Orders> list = ordersService.list();
        for (Orders orders : list) {
            long count = orderLogisticsService.count(Wrappers.<OrderLogistics>lambdaQuery().eq(OrderLogistics::getOrderId, orders.getOrderId()));
            if (count >  0L)
                ordersService.updateById(orders.setStatus(4));
        }
    }
}
